package cn.zzmx.service;

import cn.zzmx.entity.Order;
import cn.zzmx.mapper.IOrderMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.beans.Transient;
import java.util.ArrayList;
import java.util.List;




@Service
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.REPEATABLE_READ, readOnly = false)
public class IOrderServiceImpl implements IOrderService{

    @Autowired
    private IOrderMapper iOrderMapper;


    @Override
    @Transactional(readOnly = true)
    public PageInfo<Order> queryOrderAll(Integer page, Integer limit) {

        PageHelper.startPage(page,limit);
        PageInfo<Order> orderPageInfo = new PageInfo<>(iOrderMapper.queryOrderAll());
        return orderPageInfo;
    }

    @Override
    @Transactional(readOnly = true)
    public List<Order> queryOrderPassengerById(String id) {

        List<Order> orders = new ArrayList<>();
        orders.add(iOrderMapper.queryOrderPassengerById(id));
        return orders;
    }

    @Override
    public void deleteOrderById(String id) {
        iOrderMapper.deleteOrderById(id);
    }
}
